package com.lais.record.base.properties;

import com.lais.record.common.utils.RsaUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.security.PublicKey;

/**
 * @Author: luowen
 * @Description:
 * @Date: Create in 17:34 2019/11/30
 */
@ConfigurationProperties(prefix = "record.jwt")
@Data
@Slf4j
@Component
public class JwtProperties {

    private String pubKeyPath;

    private PublicKey publicKey;

    @PostConstruct
    public void init(){
        try {
            publicKey = RsaUtils.getPublicKey(pubKeyPath);
        } catch (Exception e) {
           log.error("获取公钥失败。。。");
           throw new RuntimeException("获取公钥失败");
        }
    }
}
